<template>
	<view class="">
		
	</view>	
</template>

<script>
	export default{
		data(){
			return {
				show:false,
			}
		},
		mounted() {
			setTimeout(()=>{
				if(!this.vuex_user_id){
					this.showLoginTip()
				}
			},3000)
		},
		methods:{
			showLoginTip(){
				uni.showModal({
					title: '立即登录',
					content: '登录后将推荐更优质的服务',
					success:  (res) => {
						if (res.confirm) {
							this.onConfirm()
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			onConfirm(){
				
				uni.login({
				  provider: 'weixin', //使用微信登录
				  success:  (res)=>{
				    console.log('>>>>>>>>><<<<<<<<<<<');
				    console.log(res);
					this.$network('/api/wechatMin/login',{code:res.code}).then(res=>{
						const data = res.data||{}
						const openid = data.openid||''
						const session_key = data.session_key||''
						
						uni.getUserProfile({
							provider: 'weixin',
							desc: '获取您微信昵称跟',
							success: (infoRes)=>{
								console.log('用户昵称为：' + infoRes);
							},
							fail: (infoRes)=>{
								console.log('用户昵称为：' + infoRes);
							},
						})
					})
				  },
				  fail:(res)=>{
					uni.$u.toast("登录失败:"+JSON.stringify(res))
				  }
				});
			}
		}
	}
</script>

<style>
</style>